import time
import unittest
from selenium import webdriver
from selenium.webdriver.common.by import By
from ddt import ddt,file_data
@ddt
class Login(unittest.TestCase):
    def setUp(self):
        self.driver=webdriver.Edge()
        self.driver.get('http://10.59.9.12:7001/')
        self.driver.maximize_window()

    def tearDown(self):
        time.sleep(5)
        self.driver.quit()
    @file_data('login.yaml')
    def test_a3mall_login(self,username,password,city):

        self.driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').click()
        self.driver.find_element(By.NAME,'username').send_keys(username)
        self.driver.find_element(By.NAME, 'password').send_keys(password)
        time.sleep(10)
        if city == 'F1':
            self.driver.find_element(By.CSS_SELECTOR, '.finish-btn').click()
            time.sleep(5)
            dy1=self.driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div[1]/div[2]/div[2]/ul/li[1]').text
            print(dy1)
            assert "您好，13811033962 欢迎回来！" in dy1
        else:
            self.driver.find_element(By.CSS_SELECTOR, '.finish-btn').click()
            time.sleep(5)
            dy2=self.driver.find_element(By.XPATH,'/html/body/div[4]/div/div[1]/div[1]/span[1]').text
            print(dy2)

if __name__ == '__main__':
    unittest.main()